package com.lpit.controller;

import com.lpit.dto.CommentsDto;
import com.lpit.dto.CommentsReplyDto;
import com.lpit.result.ResponseResult;
import com.lpit.service.CommentService;
import com.lpit.service.CommentsReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Yao Chen
 * 用户关于文章的评论
 */
@RestController
public class CommentsController {
    @Autowired
    private CommentService commentService;
    @Autowired
    private CommentsReplyService commentsReplyService;
    /**
     * 对文章添加评论
     * @param commentsDto
     * @return ResponseResult<Integer>
     */
    @GetMapping("/addComments")
    public ResponseResult<Integer> addComments(@RequestBody CommentsDto commentsDto){
        return commentService.addComments(commentsDto);
    }

    /**
     * 对文章的评论添加回复
     * @param commentsReplyDto
     * @return ResponseResult<Integer>
     */
    @GetMapping("/addCommentsReply")
    public ResponseResult<Integer> addCommentsReply(@RequestBody CommentsReplyDto commentsReplyDto){
        return commentsReplyService.addCommentsReply(commentsReplyDto);
    }

    /**
     * 累计评论数
     */
    @GetMapping("/countComment")
    public ResponseResult<Long> getCommentCount(){
        return commentService.getCommentCount();
    }
}
